var https = require('https');
const querystring = require('querystring')

setInterval(() => {
  var data = querystring.stringify({
    exam_id:"5bbcc04e8db9e0582d72dbff",
    current: 27
  })

  const options = {
    host:'www.ourspark.org',
    path:'/mark/get_current_class',
    method:'POST',
    headers:{
      'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'
    }
  }

  const req = https.request(options, (res) => {
    // console.log('statusCode:', res.statusCode);
    // console.log('headers:', res.headers);

    var dd = ""
    res.on('data', (d) => {
      dd += d
    });
    res.on('end', function() {
      //这里接收的参数是字符串形式,需要格式化成json格式使用
      var resultObject = JSON.parse(dd);
      console.log('-----resBody-----',resultObject.groups.length, Math.random());
    });
  });
  req.on('error', (e) => {
    console.error(e);
    console.log("\n---------------------")
  });
  req.write(data);
  req.end();
}, 5)

